<?php
header("Content-Type:text/html;charset=utf-8");
/**
 * Created by PhpStorm.
 * User: LYL
 * Date: 2015/5/16
 * Time: 16:33
 */

/**顶层接口
 * Interface IGiveGift
 */
interface IGiveGift
{
    function giveRose();
    function giveChocolate();
}

/**追求者
 * Class Follower
 */
class Follower implements IGiveGift
{
    private $girlName;

    function __construct($name='Girl')
    {
        $this->girlName=$name;
    }

    function giveRose()
    {
        echo "{$this->girlName}:这是我送你的玫瑰，望你能喜欢。<br/>";
    }

    function giveChocolate()
    {
        echo "{$this->girlName}:这是我送你的巧克力，望你能收下。<br/>";
    }
}

/**代理
 * Class Proxy
 */
class Proxy implements IGiveGift
{
    private $follower;

    function __construct($name='Girl')
    {
        $this->follower=new Follower($name);
    }

    function giveRose()
    {
        $this->follower->giveRose();
    }

    function giveChocolate()
    {
        $this->follower->giveChocolate();
    }
}


//------------------------代理模式测试代码------------------
$proxy=new Proxy('范冰冰');
$proxy->giveRose();
$proxy->giveChocolate();
